package com.dc.tinymcedemo;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/***
 * descriptions...
 * @author Diamon.Cheng
 * @date 2021/7/16
 */
@Configuration
public class Config implements WebMvcConfigurer {
    @Value("${file.save.path:file}")
    private String filePath;
    @Value("${file.mapping.path:/attachment}")
    private String fileMappingPath;
    
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        //映射程序起始位置目录下 file 文件夹作为 网络访问路径
        registry.addResourceHandler(fileMappingPath + "/**").addResourceLocations("file:" + filePath + "/");
    }
}
